<template>
  <div class="app-container">
    <div class="header">返校申请</div>
    <div class="form-content">
      <!-- 申请类型选择 -->
      <div class="radio-group">
        <label class="radio-item" @click="applyType = 'normal'">
          <div class="radio-custom" :class="{ checked: applyType === 'normal' }"></div>
          <span>申请返校</span>
          <span class="desc">适用于正常返校</span>
        </label>
        <label class="radio-item" @click="applyType = 'delay'">
          <div class="radio-custom" :class="{ checked: applyType === 'delay' }"></div>
          <span>申请延期返校</span>
          <span class="desc">适用于特殊情况，延期返校</span>
        </label>
      </div>

      <!-- 正常返校流程 -->
      <div class="process-section" v-if="applyType === 'normal'">
        <h3>请假流程</h3>
        <div class="approver-item">
          <span class="label">审批人(导师)</span>
          <span class="name">张三</span>
          <span class="status">√</span>
        </div>
        <view id="line_1">
          会签-------------------------1人通过即可进入下一节点
        </view>
        <div class="approver-item">
          <span class="label">审批人(导师)</span>
          <span class="name">王京</span>
          <span class="comment">"本月不允许续请假，马上要考试了！"</span>
        </div>
      </div>

      <!-- 延期返校信息（ -->
      <div class="delay-section" v-else>
        <h3>延期返校信息</h3>
        <div class="form-item">
          <label>延期返校时间</label>
          <textarea
              v-model="delayDate"
              placeholder="请填写格式：YYYY-MM-DD（例：2024-09-15）"></textarea>
        </div>
        <div class="form-item">
          <label>返校理由</label>
          <textarea placeholder="请输入返校理由" maxlength="100" v-model="reason"></textarea>
        </div>

        <h3>返校申请流程</h3>
        <div class="approver-item">
          <span class="label">审批人(导师)</span>
          <span class="name">张三</span>
        </div>
        <view id="line_1">
          会签-------------------------1人通过即可进入下一节点
        </view>
        <div class="approver-item">
          <span class="label">审批人(导师)</span>
          <span class="name">王京</span>
        </div>
        <div class="approver-item">
          <span class="label">审批人(学校党委副书记)</span>
          <span class="name">贺原</span>
        </div>
      </div>

      <button class="submit-btn" @click="submit">提交申请</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ReturnApply',
  data() {
    const today = new Date().toISOString().split('T')[0];
    return {
      applyType: 'normal',
      delayDate: today,
      reason: ''
    };
  },
  methods: {
    submit() {
      // 可在此处添加文本格式校验（可选），例如检查是否符合YYYY-MM-DD
      const dateReg = /^\d{4}-\d{2}-\d{2}$/;
      if (this.applyType === 'delay' && !dateReg.test(this.delayDate)) {
        alert('请按提示格式填写延期返校时间（例：2024-09-15）');
        return;
      }
      alert('申请已提交，等待审批');
    }
  }
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-container {
  width: 375px;
  margin: 20px auto;
  background-color: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header {
  background-color: #007bff;
  color: #fff;
  padding: 15px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
}

.form-content {
  padding: 15px;
}

.radio-group {
  margin-bottom: 20px;
}

.radio-item {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  cursor: pointer;
}

.radio-custom {
  width: 16px;
  height: 16px;
  border: 1px solid #ccc;
  border-radius: 50%;
  margin-right: 8px;
  position: relative;
  transition: all 0.2s;
}

.radio-custom.checked {
  background-color: #007bff;
  border-color: #007bff;
}

.radio-custom.checked::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.radio-item .desc {
  font-size: 12px;
  color: #666;
  margin-left: 5px;
}

.process-section,
.delay-section {
  margin-bottom: 20px;
}

.process-section h3,
.delay-section h3 {
  font-size: 16px;
  margin-bottom: 10px;
  color: #333;
}

.approver-item {
  margin-bottom: 10px;
}

.approver-item .label {
  display: block;
  font-size: 14px;
  color: #666;
  margin-bottom: 3px;
}

.approver-item .name {
  font-weight: 600;
}

.approver-item .status {
  color: #28a745;
}

.approver-item .comment {
  font-size: 13px;
  color: #555;
}

.form-item {
  margin-bottom: 15px;
}

.form-item label {
  display: block;
  font-size: 14px;
  color: #666;
  margin-bottom: 5px;
}

.form-item input,
.form-item textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.form-item textarea {
  min-height: 80px;
  resize: none;
}

.submit-btn {
  width: 100%;
  padding: 12px;
  background-color: #007bff;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
}

.submit-btn:hover {
  background-color: #0056b3;
}
#line_1{
  color: #8f939c;
  font-size: 13px;
}
</style>